package 字符流;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

public class 集合到文件1 {
    public static void main(String[] args) throws IOException {
        /*创建字符缓冲输入流对象*/
        BufferedReader br = new BufferedReader(new FileReader("D:\\111\\222.txt"));
        /*创建ArrayList集合对象*/
        ArrayList<String> array = new ArrayList<>();
        /*调用对象方法读取数据*/
        String line;
        while ((line=br.readLine())!=null){
            /*把读取到的字符数据存储到集合里面*/
            array.add(line);
        }
        /*释放资源*/
        br.close();
        /*遍历集合*/
        for (String s:array) {
            System.out.println(s);
        }
    }
}